package com.neighbor.neighborhooduser.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.neighbor.neighborhooduser.pojo.ItemOrders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neighbor.neighborhooduser.pojo.OrderStatus;
import com.neighbor.neighborhooduser.pojo.OrderWithItemDTO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 物品交易订单表 Mapper 接口
 * </p>
 *
 * @author song
 * @since 2025-09-22 09:13:04
 */
//@RequestParam Integer itemId,
//@RequestParam Integer buyerId,
//@RequestParam Integer sellerId,
//@RequestParam Integer type,
//@RequestParam Integer price,
//@RequestParam Integer rentDays,
//@RequestParam Integer startDate
public interface IItemOrdersDao extends BaseMapper<ItemOrders> {
//        Integer createOrder(@Param(""))
    Integer createOrder(@Param("order") ItemOrders order);
    ItemOrders getByOrderNumber(@Param("orderNumber") String orderNumber);

    Integer updateStatus(@Param("id") Integer id);
    List<OrderWithItemDTO> findBySellerAndStatus(@Param("sellerId") Integer sellerId, @Param("status") OrderStatus orderStatus);

    List<OrderWithItemDTO> findByBuyerAndStatus(@Param("buyerId") Integer buyerId, @Param("status") OrderStatus orderStatus);

    // 查询用户所有相关订单（买家和卖家）
    List<OrderWithItemDTO> findByUserIdAndItemTitle(
            @Param("userId") Integer userId,
            @Param("title") String title);


    //两个都是获取作为卖家或者买家的订单
    List<OrderWithItemDTO> findSellerOrdersWithDetails(Integer sellerId);

    List<OrderWithItemDTO> findBuyerOrdersWithDetails(Integer buyerId);

    OrderWithItemDTO findOrderDetailsById(@Param("orderId") Integer orderId);
}
